
<%@page import="persistence.AccesoBD"%>
<%@page import="java.util.LinkedList"%>
<%@page import="entidades.Configuracion"%>
<%@page import="entidades.Customer"%>
import javax.servlet.http.HttpServletRequest;

<%@page import=" Security.MD5" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
         
    <body>
        <%
            AccesoBD abd=(AccesoBD)session.getAttribute("conex");
            String layer="hidden";
            
            try{
            abd.iniciarTransaccion();
            MD5 f= new MD5();
            String username=request.getParameter("user");
            String password=request.getParameter("pass");
            String condicion= "usuario=='"+username+"'";
            LinkedList <Configuracion> a= new LinkedList();
            a=abd.listar(new Configuracion(),condicion);
            //out.print(f.md5("d"));
            //if(a.isEmpty()){
            //out.println("if"+a.getFirst().getNombre());
            //}else{
              //          out.println("el"+a);

            //}
                
           if ((a.getFirst().getUsuario().compareTo(username)==0)&&((a.getFirst().getPassword().compareTo(password)==0))){
            // if(a.getFirst().getPassword().compareTo(f.md5(password))==0){
          //if((a.getFirst().g  etPassword())==(f.md5(password))){
               session.setAttribute("username", username );
               response.sendRedirect("Admin.jsp");
           }
           if((a.isEmpty())&((a.getFirst().getPassword().compareTo(password)!=0))){
                out.print(f.md5("sadsadsadsadsadsadsadasd"));
                layer="visible";
                session.setAttribute("div",layer);
                response.sendRedirect("Login.jsp");
           }
            abd.concretarTransaccion();
        }catch (Exception e){
            abd.rollbackTransaccion();               
   
                              }
    %>
    </body>
        
    
</html>
